import 'dart:convert';

import 'package:duqin/http/http.dart';
import 'package:flutter/services.dart';

class SongService {
  static const String rootPath = '/api/song';
  static const String listPath = '$rootPath/list';
  static const String infoPath = '$rootPath/info';

  /// 列表请求
  static Future getSongs({int page = 1, int limit = 10}) async {
    // final response = await Http.post(
    //   listPath,
    //   data: {'limit': 10, 'page': page},
    // );
    // Map<String, dynamic> result = response['page'];
    String data = await rootBundle.loadString("assets/data/song.json");
    Map<String, dynamic> result = jsonDecode(data);
    return result;
  }

  /// 详情请求
  static Future getSongInfo(int id) async {
    final response = await Http.get('$infoPath/$id');
    Map<String, dynamic> info = response['info'];
    return info;
  }
}
